<%@ page contentType="text/html;charset=utf-8"%>
<%@page import="com.course.db.*"%>
<%@page import="java.sql.*"%>
<%@page import="java.util.*"%>

<%
	request.setAttribute("layout","main.jsp");
	request.setAttribute("page_title","温岭选课系统-课程列表");
%>
<% 
	int i = 0;
  	List<Hashtable<String, String>> course_list = (List<Hashtable<String, String>>) request.getAttribute("CourseList");
	Iterator<Hashtable<String, String>> course_it;
 %>

<!DOCTYPE html>
<html lang="en" dir="ltl">
<head>

<meta charset="utf-8" />
<title>${page_title}</title>

<%  
	String path = request.getContextPath();  
	String basePath = request.getScheme()+"://"+request.getServerName()+
		(request.getServerPort() == 80 ? "" : (":"+request.getServerPort())) +path+"/";  
	String   userName   =   (String)session.getAttribute("userName");
	String   userType   =   (String)session.getAttribute("userType");
	String 	 menus=(String)session.getAttribute("menus");
 	if(userName==null){
 		//String newLocn = basePath+"login.jsp";
 		//request.getRequestDispatcher(newLocn).forward(request,response);
 		//return;
 	}
%>

<script type="text/javascript">
	var base_path = "<%=basePath%>";
	var user_name="<%=userName%>";
	var user_type="<%=userType%>";
	var menus="<%=menus%>";
</script>

<base href="<%=basePath%>">
<link rel="stylesheet" href="css/reset.css" />
<link rel="stylesheet" href="css/text.css" />
<link rel="stylesheet" href="css/960.css" />
<link rel="stylesheet" href="css/demo.css" />
<link rel="stylesheet" href="css/style.css" />
<script type='text/javascript' src='js/jquery-1.5.2.min.js'></script>
<script type='text/javascript'>
	$(document).ready(function() {
		if(user_name=="null"){
			window.location.href=base_path+"login.jsp";
		}
		$("#center").css(
			    "min-height", function(index, value) {return $(window).height()-$("#top").height()-$("#menubar").height()-$("#bottom").height();}
			  );
	});
	function logout(){
		   $.ajax({
				url: base_path+"../Login/logout.do",
	            data: "{}", 
				
				success: function(data, textStatus){
					
				},
				complete: function(XMLHttpRequest, textStatus){
					window.location.href=base_path+"login.jsp";

				},
				error: function(){
				}
			});
	   }
	 function getDate(){     
		 var date=new Date();     
		 var month=date.getMonth()+1;     
		 var day=date.getDate();     
		     
		 if(month.toString().length == 1){  //或者用if (eval(month) <10) {month="0"+month}     
		     
		 month='0'+month;     
		 }     
		 if(day.toString().length == 1){     
		 day='0'+day;     
		 }     
		 return date.getFullYear()+'年'+month+'月'+day+''+date.toLocaleString().substring(date.toLocaleString().length- 10)+'  '+'星期'+'日一二三四五六'.charAt(date.getDay());      
	 }     
</script>
 
</head>
<body style="padding-bottom:0;margin-bottom:0;">
<div class="container_12" id="container" style="padding-bottom:0;margin-bottom:0;">
  	<div class="grid_6" id="top" style="height:60px;">
  			<img alt="数字化校园" src="images/preloader.png"/>
  	</div>
  	<div class="grid_6" style="vertical-align:middle;height:60px;">
  		<table style="margin-top:10px;width:100%;font-size:13px;">
  			<tr style="height:25px;margin:0;padding:0;"  valign=middle>
  				<td width=70 align=right style="font-weight:bold;border:0;">当前用户：</td>
  				<td  width=70 align=left style="font-weight:bold;border:0;"><%=userName%></td>
  				<td align=right style="font-size:14px;text-align:center;font-style:italic;border:0;">
  					欢迎登录使用选课系统
  				</td>
  				
  			</tr>
  			<tr style="height:25px;margin:0;padding:0;"  valign=middle>
  				<td align=left style="font-weight:bold;border:0;">用户角色：</td>
  				<td align=right style="font-weight:bold;border:0;"><%=userType%></td>
  				<td align=right style="vertical-align:bottom;font-size:12px;text-align:right;border:0;">
  					当前系统时间：<span id="time">     
			 <script>     
			 document.getElementById('time').innerHTML=getDate();     
			 setInterval("document.getElementById('time').innerHTML=getDate();",1000);     
			 </script>      
			</span>  
  				</td>
  			</tr>
  			
  		</table>
  				
  	</div>
  	<div class="clear"></div>
  	
  	<div class="grid_12"  style="height:50px;" id="menubar">
	  	<div class="menucontainer">
			<div class="menu">
				<ul id="menus">
					<%=menus%>
				</ul>
			</div>
		</div>
  	</div>
  <div class="clear"></div>
  <div class="grid_12" id="center" style="border:1px solid gray;text-align:center;">
  <link href="css/jquery.ui.tabs.css" rel="stylesheet">
	<link href="css/jquery.ui.theme.css" rel="stylesheet">
	<script src="js/jquery-1.5.2.min.js"></script>
	<script src="js/jquery-ui-1.8.11.custom.min.js"></script>
	<script src="js/jquery.ui.tabs.js"></script>
	<script>
	$(function() {
		$( "#tabs" ).tabs();
	});
	</script>
  		<div style="width:100%; margin:1px;text-align:center;margin-top:10px;margin-bottom:50px;">
 	<p style="border:0;font-size:14px;padding-bottom:0;text-align:center;">
 		<b>我的开课记录</b>
  		<select>
  			<option value="全部">全部</option>
  			<option value="2011年第一学期">2011年第一学期</option>
  			<option value="2011年第二学期">2011年第二学期</option>
  			<option value="2012年第一学期">2012年第一学期</option>
  		</select>
	</p>
	  <div id="tabs" style="height:500px;width:90%;margin-left:5%;">
		<ul>
			<li><a href="#tabs-1">已开设课程</a></li>
			<li><a href="#tabs-2">历史申请记录</a></li>
		</ul>
		<div id="tabs-1" style="width:100%;margin-left:0;padding-left:0;margin-top:20px;">
			<table>
		    		<tbody>
		              <tr height="32" bgcolor="#f0f0f0">
		              		<td align="center" width="10%">学期</td>
		                    <td align="center" width="8%">课程类型</td>
		                    <td align="center" width="7%">课程编号</td>
		                    <td align="center" width="14%">课程名称</td>
		                    <td align="center" width="20%">上课时间|地点</td>
		                    <td align="center" width="6%">人数限额<br>
		                      (最多/最少)</td>
		                    <td align="center" width="6%">已选人数</td>
		                    <td align="center" width="6%">课程简介</td>
		             </tr>
		          <%
		           course_it = course_list.iterator();
		        	while(course_it.hasNext())
							{
								Hashtable<String, String> course_hash  = course_it.next();
					%>
					<tr height="25" bgcolor="#ffffff">
			  		 <td align="center"><%=course_hash.get("year")%><%=course_hash.get("openterm")%></td>
		             <td align="center"><%=course_hash.get("type")%></td>
		             <td align="center"><%=course_hash.get("classno")%></td>
		             <td align="center"><%=course_hash.get("name")%></td>
		             <td align="center"><%=course_hash.get("teach_time")%>|<%=course_hash.get("teach_location")%></td>
		             <td align="center"><%=course_hash.get("students_high")%>/<%=course_hash.get("students_low")%></td>
		             <td align="center"><%=course_hash.get("num_of_students")%></td>
		             <td align="center"><a href="Teacher/coursedetail.do?courseId=<%=course_hash.get("Id")%>"  target="_blank">[查看]</a></td>
		          </tr>
		          <%
		          }
		          %>
		      </tbody>
		   </table>
		</div>
		<div id="tabs-2" style="width:100%;margin-left:0;padding-left:0;margin-top:20px;">
			<table>
		    		<tbody>
		              <tr height="32" bgcolor="#f0f0f0">
		              		<td align="center" width="10%">学期</td>
		                    <td align="center" width="8%">课程类型</td>
		                    <td align="center" width="7%">课程编号</td>
		                    <td align="center" width="14%">课程名称</td>
		                  <td align="center" width="6%">人数限额<br>
                      (最多/最少)</td>
		                    <td align="center" width="6%">审批状态</td>
		                    <td align="center" width="6%">详细</td>
		                    
		             </tr>
		            <%
		           course_it = course_list.iterator();
		        	while(course_it.hasNext())
							{
								Hashtable<String, String> course_hash  = course_it.next();
							%>
					<tr height="25" bgcolor="#ffffff">
			  		 <td align="center"><%=course_hash.get("year")%><%=course_hash.get("openterm")%></td>
		             <td align="center"><%=course_hash.get("type")%></td>
		             <td align="center"><%=course_hash.get("classno")%></td>
		             <td align="center"><%=course_hash.get("name")%></td>
		             <td align="center"><%=course_hash.get("students_high")%>/<%=course_hash.get("students_low")%></td>
		             <td align="center">
		             	<% if(course_hash.get("checkstatus").equalsIgnoreCase("0")){%>
		             		审核中
		             	<% }else if(course_hash.get("checkstatus").equalsIgnoreCase("1")){ %>
		             		审核通过
		             	<%}else{ %>
		             		审核不通过
		             	<%} %>
		             </td>
		             <td align="center"><a href="Teacher/coursedetail.do?courseId=<%=course_hash.get("Id")%>"  target="_blank">[查看]</a></td>
		          </tr>
		          <%
		          }
		          %>
		      </tbody>
		   </table>
		</div>
	</div>
</div>
  </div>
  <div class="clear"></div>
  <div class="grid_12"  style="height:50px;" id="bottom">
	  <p style="border:0;font-size:13px;">
		   浙江省温岭中学  CopyRight：2011-2012           杭州池墨科技有限公司
	  </p> 	  	
  </div>
 
</div>
</body>
</html>